#include "Bucket.h"
#include "Resource/ResourceManager.h"

CBucket::CBucket()
{
	mObjectClassification = ObjectClassification_Bucket;
	this->autorelease();
}
CBucket::~CBucket()
{
	gBoxWorld->DestroyBody(mBody);
	gBoxWorld->DestroyBody(mBucketBody);
}
void CBucket::Load(CCDictionary* bucketDic)
{
	CCPoint pos = CCPointFromString(bucketDic->valueForKey("pos")->getCString());
	CCSize winSize = CCDirector::sharedDirector()->getWinSize();
	CCString rot =  bucketDic->valueForKey("rot")->getCString();
	int color = bucketDic->valueForKey("color")->intValue();
	mObjectColorType = color;

	mBucketBody = ResourceManager->GetBody(BucketBody);
	mBucketBody->SetTransform(b2Vec2( pos.x * winSize.width/kPTM_RATIO,pos.y*winSize.height/kPTM_RATIO ),float32(CC_DEGREES_TO_RADIANS(rot.floatValue())) );

	mBody = ResourceManager->GetBody(BucketCollision);
	mBody->SetUserData(this);
	mBody->SetTransform(b2Vec2( pos.x * winSize.width/kPTM_RATIO,pos.y*winSize.height/kPTM_RATIO ),float32(CC_DEGREES_TO_RADIANS(rot.floatValue())) );
}